//app.js
App({
  onLaunch: function () {
    wx.switchTab({
      url: 'view/join/join',
    });

  },

  onShareAppMessage: function () {
    var that = this;
    //var ims = that.data.userInfo.headimg;
    return {
      title: '首页',
      path: '/home/index/index?id=12',
      imageUrl: ""

    }
  },

  //通用用的异步域名
  getUrl:function(){
    var Urlcom ='http://jbc.com';
    return Urlcom;
  },

  //公用分享页面
  getShare:function(){
    var data = {
      title: '首页',
      path: '/home/index/index',
      imageUrl: 'https://thumbnail0.baidupcs.com/thumbnail/026036d2adb331461598d813cc168991?fid=21919441-250528-941152646095762&time=1543208400&rt=sh&sign=FDTAER-DCb740ccc5511e5e8fedcff06b081203-KyIphXWsq40y0OB0LLlFkQa%2F0eM%3D&expires=8h&chkv=0&chkbd=0&chkpc=&dp-logid=8796873517441869887&dp-callid=0&size=c710_u400&quality=100&vuk=-&ft=video'
    };
    wx.getStorage({
      key: 'user',
      success: function (res) { 
        data.path = data.path + "/?id=" + res.data.id;
      }
    });

    return data;
     
   
  },


  //第一种底部    
  editTabBar: function () {
    //使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组，数组最后一个就是当前页面。     
    var curPageArr = getCurrentPages();    //获取加载的页面    
    var curPage = curPageArr[curPageArr.length - 1];    //获取当前页面的对象    
    var pagePath = curPage.route;    //当前页面url    
    if (pagePath.indexOf('/') != 0) { pagePath = '/' + pagePath; }
    var tabBar = this.globalData.tabBar;
    for (var i = 0; i < tabBar.list.length; i++) {
      tabBar.list[i].active = false;
      if (tabBar.list[i].pagePath == pagePath) {
        tabBar.list[i].active = true;    //根据页面地址设置当前页面状态          
      }
    }
    curPage.setData({ tabBar: tabBar });

  },

  globalData: {
    //第一种底部导航栏显示    
    tabBar: {
      "color": "#444",
      "backgroundColor": "#fff",
      "selectedColor": "#eb0000",
      "list": [
        {
          "pagePath": "/home/index/index",
          "text": "首页",
          "iconPath": "http://phtvvz9br.bkt.clouddn.com/foot_1.png",
          "selectedIconPath": "http://phtvvz9br.bkt.clouddn.com/foot1.png",
          "clas": "menu-item",
          "selectedColor": "#eb0000",
          active: true
        },
        {
          "pagePath": "/view/car/car",
          "text": "选车",
          "iconPath": "http://phtvvz9br.bkt.clouddn.com/foot_2.png",
          "selectedIconPath": "http://phtvvz9br.bkt.clouddn.com/foot2.png",
          "selectedColor": "#eb0000",
          "clas": "menu-item",
          active: false
        },
        {
          "pagePath": "/view/help/help",
          "text": "订单",
          "iconPath": "http://phtvvz9br.bkt.clouddn.com/foot_3.png",
          "selectedIconPath": "http://phtvvz9br.bkt.clouddn.com/foot3.png",
          "selectedColor": "#eb0000",
          "clas": "menu-item",
          active: false
        },
        {
          "pagePath": "/view/about/about",
          "text": "我的",
          "iconPath": "http://phtvvz9br.bkt.clouddn.com/foot_4.png",
          "selectedIconPath": "http://phtvvz9br.bkt.clouddn.com/foot4.png",
          "selectedColor": "#eb0000",
          "clas": "menu-item",
          active: false
        }
      ],
      "position": "bottom"
    },
  }
})  
